#include "_video.h"

VIDEO_ERROR play_start(char* fname, VIDEO_CB cb)
{
	if (g_video_context)
	{
		return VIDEO_ERROR_01;
	}

	VIDEO_ERROR res = 0;
	if (res == 0)res = _video_init();
	if (res == 0)res = _play_start(fname, cb);
	if (res)play_stop();
	return res;
}

VIDEO_ERROR play_stop()
{
	if (g_video_context == 0)
	{
		return VIDEO_ERROR_10;
	}

	_play_stop();
	_video_free();
	return VIDEO_ERROR_OK;
}

VIDEO_ERROR play_pause()
{
	if (g_video_context == 0)
	{
		return VIDEO_ERROR_10;
	}

	VIDEO_ERROR res = 0;
	res = _play_pause();
	return res;
}

VIDEO_ERROR play_resume()
{
	if (g_video_context == 0)
	{
		return VIDEO_ERROR_10;
	}

	VIDEO_ERROR res = 0;
	res = _play_resume();
	return res;
}

VIDEO_ERROR play_seek(int offset)
{
	if (g_video_context == 0)
	{
		return VIDEO_ERROR_10;
	}

	VIDEO_ERROR res = 0;
	res = _play_seek(offset);
	return res;
}

VIDEO_ERROR play_set_volume(unsigned char volume)
{
	if (g_video_context == 0)
	{
		return VIDEO_ERROR_10;
	}

	VIDEO_ERROR res = 0;
	res = _play_set_volume(volume);
	return res;
}

VIDEO_ERROR record_start(char* fname, VIDEO_CB cb)
{
	if (g_video_context)
	{
		return VIDEO_ERROR_01;
	}

	VIDEO_ERROR res = 0;
	if (res == 0)res = _video_init();
	if (res == 0)res = _record_start(fname, cb);
	if (res)record_stop();
	return res;
}

VIDEO_ERROR record_stop()
{
	if (g_video_context == 0)
	{
		return VIDEO_ERROR_10;
	}

	_record_stop();
	_video_free();
	return VIDEO_ERROR_OK;
}

VIDEO_ERROR record_pause()
{
	if (g_video_context == 0)
	{
		return VIDEO_ERROR_10;
	}

	VIDEO_ERROR res = 0;
	res = _record_pause();
	return res;
}

VIDEO_ERROR record_resume()
{
	if (g_video_context == 0)
	{
		return VIDEO_ERROR_10;
	}

	VIDEO_ERROR res = 0;
	res = _record_resume();
	return res;
}

